import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDWelfareSign {
	/**序列*/
	id,
	/**周数*/
	week,
	/**天数*/
	day,
	/**每日奖励*/
	reward,

	/**枚举数量*/
	EnumCount
}



export class CDWelfareSign{
	/**序列*/
	public id: number;
	/**周数*/
	public week: number;
	/**天数*/
	public day: number;
	/**每日奖励*/
	public reward: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDWelfareSign.id: return this.id;
			case E_CDWelfareSign.week: return this.week;
			case E_CDWelfareSign.day: return this.day;
			case E_CDWelfareSign.reward: return this.reward;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDWelfareSign.id: this.id = v; break;
			case E_CDWelfareSign.week: this.week = v; break;
			case E_CDWelfareSign.day: this.day = v; break;
			case E_CDWelfareSign.reward: this.reward = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDWelfareSign> = new HashMap<number, CDWelfareSign>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDWelfareSign[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDWelfareSign();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].week = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].day = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].reward = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDWelfareSign{
		return this.datas ? this.datas.get(id) : null;
	}
}
